/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package agb.Conexion;


/**
 *
 * @author Administrator
 */
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.sql.*;


/**
 *
 * @author 
 */
public class Conexion {

    //public static String url = "jdbc:postgresql://10.1.3.59:5432/dbcolegioprueba?autoReconnect=true";

 public static String url = "jdbc:postgresql://192.168.1.35:5432/dbcolegio?autoReconnect=true";

   //public static String url = "jdbc:postgresql://201.230.203.143:5432/dbcolegio?autoReconnect=true";

  //public static String url = "jdbc:postgresql://201.230.203.143:5432/dbcolegio?autoReconnect=true";
    




    public static String Clase = "org.postgresql.Driver";
    public static String user = "postgres";
    public static String pass = "adminbeta";

    public static Connection getConexion(){
        
        try{
            
            Class.forName(Clase);
               
            return DriverManager.getConnection(url, user, pass);

        }catch(SQLException ex){

             System.out.println("UrllllllllllOcalizacion: "+ex.getLocalizedMessage()+" Mensaje: "+ex.getSQLState()+" Mensaje2: "+ex.getMessage());

            ex.printStackTrace();
        }catch(Exception ex){
            ex.printStackTrace();
        }
        return null;
    }

    public static void anularTransaccion(Connection cn){
        try{
            cn.rollback();
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }


    public static void confirmarTransaccion(Connection cn){
        try{
            cn.commit();
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }

   public static void cerrarConexion(Connection cn){
        try{
            cn.close();
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }

   public static void cerrarResulset(ResultSet rs){
        try{
            rs.close();
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }

   public static void cerrarPreparedStatement(PreparedStatement ps){
        try{
            ps.close();
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }

}